package com.tedu.parkinglot.admin.service.impl;

import com.tedu.parkinglot.admin.mapper.AdminMapper;
import com.tedu.parkinglot.admin.pojo.dto.AdminLoginParam;
import com.tedu.parkinglot.admin.pojo.vo.AdminVO;
import com.tedu.parkinglot.admin.service.AdminService;
import com.tedu.parkinglot.base.exception.ServiceException;
import com.tedu.parkinglot.base.response.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;



@Slf4j
@org.springframework.stereotype.Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;
    @Override
    public AdminVO login(AdminLoginParam adminLoginParam) {
        log.debug("adminService,adminLoginParam:{}",adminLoginParam);
        AdminVO adminVO = adminMapper.selectByName(adminLoginParam.getName());
        if (adminVO==null){
            throw new ServiceException(StatusCode.NAME_ERROR);
        }
        if(adminVO.getPassword().equals(adminLoginParam.getPassword())){
//            adminVO.setPassword(null);
            return adminVO;
        }
        return null;
    }
}
